
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>docker02 安装docker · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="docker03 docker原理.html" />
    
    
    <link rel="prev" href="docker01 docker能干嘛.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="docker01 docker能干嘛.html">
            
                <a href="docker01 docker能干嘛.html">
            
                    
                    docker01 docker能干嘛
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3" data-path="docker02 安装docker.html">
            
                <a href="docker02 安装docker.html">
            
                    
                    docker02 安装docker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="docker03 docker原理.html">
            
                <a href="docker03 docker原理.html">
            
                    
                    docker03 docker原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="docker04 镜像基本命令.html">
            
                <a href="docker04 镜像基本命令.html">
            
                    
                    docker04 镜像基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="docker05 容器基本命令.html">
            
                <a href="docker05 容器基本命令.html">
            
                    
                    docker05 容器基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="docker06 常用其他命令.html">
            
                <a href="docker06 常用其他命令.html">
            
                    
                    docker06 常用其他命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="docker07 进入当前正在运行的容器.html">
            
                <a href="docker07 进入当前正在运行的容器.html">
            
                    
                    docker07 进入当前正在运行的容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="docker08 部署nginx.html">
            
                <a href="docker08 部署nginx.html">
            
                    
                    docker08 部署nginx
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="docker09 部署tomcat.html">
            
                <a href="docker09 部署tomcat.html">
            
                    
                    docker09 部署tomcat
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="docker10 可视化面板.html">
            
                <a href="docker10 可视化面板.html">
            
                    
                    docker10 可视化面板
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="docker11 镜像原理.html">
            
                <a href="docker11 镜像原理.html">
            
                    
                    docker11 镜像原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="docker12 commit镜像.html">
            
                <a href="docker12 commit镜像.html">
            
                    
                    docker12 commit镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="docker13 容器数据卷.html">
            
                <a href="docker13 容器数据卷.html">
            
                    
                    docker13 容器数据卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="docker14 具名挂载和匿名挂载.html">
            
                <a href="docker14 具名挂载和匿名挂载.html">
            
                    
                    docker14 具名挂载和匿名挂载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="docker15 初始dockerfile.html">
            
                <a href="docker15 初始dockerfile.html">
            
                    
                    docker15 初始dockerfile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="docker16 数据卷容器.html">
            
                <a href="docker16 数据卷容器.html">
            
                    
                    docker16 数据卷容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="docker17 dockerFile.html">
            
                <a href="docker17 dockerFile.html">
            
                    
                    docker17 dockerFile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="docker18 dockerFile基本命令.html">
            
                <a href="docker18 dockerFile基本命令.html">
            
                    
                    docker18 dockerFile基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="docker19 构建自己的centos.html">
            
                <a href="docker19 构建自己的centos.html">
            
                    
                    docker19 构建自己的centos
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="docker20 发布镜像.html">
            
                <a href="docker20 发布镜像.html">
            
                    
                    docker20 发布镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="docker21 网络详情.html">
            
                <a href="docker21 网络详情.html">
            
                    
                    docker21 网络详情
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.23" data-path="docker22 容器互联.html">
            
                <a href="docker22 容器互联.html">
            
                    
                    docker22 容器互联
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.24" data-path="docker23 自定义网络.html">
            
                <a href="docker23 自定义网络.html">
            
                    
                    docker23 自定义网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.25" data-path="docker24 SpringBoot 微服务打包Docker镜像.html">
            
                <a href="docker24 SpringBoot 微服务打包Docker镜像.html">
            
                    
                    docker24 SpringBoot 微服务打包Docker镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.26" data-path="docker25 dockerFile_demo.html">
            
                <a href="docker25 dockerFile_demo.html">
            
                    
                    docker25 dockerFile_demo
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >docker02 安装docker</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="docker&#x5B89;&#x88C5;">Docker&#x5B89;&#x88C5;</h3>
<h4 id="docker&#x57FA;&#x672C;&#x7684;&#x7EC4;&#x6210;">docker&#x57FA;&#x672C;&#x7684;&#x7EC4;&#x6210;</h4>
<p><strong>&#x955C;&#x50CF;(image):</strong>
docker&#x955C;&#x50CF;&#x5C31;&#x597D;&#x6BD4;&#x662F;&#x4E00;&#x4E2A;&#x6A21;&#x677F;,&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8FD9;&#x4E2A;&#x6A21;&#x677F;&#x6765;&#x521B;&#x5EFA;&#x5BB9;&#x5668;&#x670D;&#x52A1;,tomcat&#x955C;&#x50CF;===&gt;run===&gt; tomcat01&#x5BB9;&#x5668;(&#x63D0;&#x4F9B;&#x670D;&#x52A1;&#x5668;),&#x901A;&#x8FC7;&#x8FD9;&#x4E2A;&#x955C;&#x50CF;&#x53EF;&#x4EE5;&#x521B;&#x5EFA;&#x591A;&#x4E2A;&#x5BB9;&#x5668;(&#x6700;&#x7EC8;&#x670D;&#x52A1;&#x8FD0;&#x884C;&#x6216;&#x8005;&#x9879;&#x76EE;&#x8FD0;&#x884C;&#x5C31;&#x662F;&#x5728;&#x5BB9;&#x5668;&#x4E2D;&#x7684;)</p>
<p><strong>&#x5BB9;&#x5668;(container)</strong>
Docker&#x5229;&#x7528;&#x5BB9;&#x5668;&#x6280;&#x672F;,&#x72EC;&#x7ACB;&#x8FD0;&#x884C;&#x4E00;&#x4E2A;&#x6216;&#x8005;&#x4E00;&#x4E2A;&#x7EC4;&#x5E94;&#x7528;,&#x901A;&#x8FC7;&#x955C;&#x50CF;&#x6765;&#x521B;&#x5EFA;&#x7684; &#x542F;&#x52A8;,&#x505C;&#x6B62;,&#x5220;&#x9664;,&#x57FA;&#x672C;&#x547D;&#x4EE4;! &#x76EE;&#x524D;&#x5C31;&#x53EF;&#x4EE5;&#x628A;&#x8FD9;&#x4E2A;&#x5BB9;&#x5668;&#x7406;&#x89E3;&#x4E3A;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;linux&#x7CFB;&#x7EDF;</p>
<p><strong>&#x4ED3;&#x5E93;(repository)</strong>
&#x4ED3;&#x5E93;&#x5C31;&#x662F;&#x5B58;&#x653E;&#x955C;&#x50CF;&#x7684;&#x5730;&#x65B9;,!&#x6211;&#x4EEC;&#x8FD9;&#x4E2A; &#x4ED3;&#x5E93;&#x5206;&#x4E3A;&#x516C;&#x6709;&#x4ED3;&#x5E93;&#x548C;&#x79C1;&#x6709;&#x4ED3;&#x5E93;!</p>
<p><strong>Docker Hub &#x963F;&#x91CC;&#x4E91;... &#x7F51;&#x6613;&#x4E91; &#x534E;&#x4E3A;&#x4E91; &#x90FD;&#x6709;&#x5BB9;&#x5668;&#x670D;&#x52A1;&#x5668;(&#x914D;&#x7F6E;&#x955C;&#x50CF;&#x52A0;&#x901F;...)</strong></p>
<hr>
<blockquote>
<p>&#x73AF;&#x5883;&#x67E5;&#x770B;</p>
</blockquote>
<pre><code class="lang-shell"># &#x7CFB;&#x7EDF;&#x5185;&#x6838;&#x662F; 3.10 &#x4EE5;&#x4E0A;&#x7684;
[root@izijy66dzll7bdz /]# uname -r  
3.10.0-514.26.2.el7.x86_64

[root@izijy66dzll7bdz /]# cat etc/os-release 
NAME=&quot;CentOS Linux&quot;
VERSION=&quot;7 (Core)&quot;
ID=&quot;centos&quot;
ID_LIKE=&quot;rhel fedora&quot;
VERSION_ID=&quot;7&quot;
PRETTY_NAME=&quot;CentOS Linux 7 (Core)&quot;
ANSI_COLOR=&quot;0;31&quot;
CPE_NAME=&quot;cpe:/o:centos:centos:7&quot;
HOME_URL=&quot;https://www.centos.org/&quot;
BUG_REPORT_URL=&quot;https://bugs.centos.org/&quot;

CENTOS_MANTISBT_PROJECT=&quot;CentOS-7&quot;
CENTOS_MANTISBT_PROJECT_VERSION=&quot;7&quot;
REDHAT_SUPPORT_PRODUCT=&quot;centos&quot;
REDHAT_SUPPORT_PRODUCT_VERSION=&quot;7&quot;
</code></pre>
<h3 id="centos&#x5B89;&#x88C5;docker">CentOs&#x5B89;&#x88C5;docker</h3>
<p><img src="./imgs/&#x5FAE;&#x4FE1;&#x622A;&#x56FE;_20210321135834.png" alt=""></p>
<pre><code class="lang-shell"># 1. &#x5378;&#x8F7D;&#x65E7;&#x7684;&#x7248;&#x672C;
$ sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
# 2. &#x5B89;&#x88C5;&#x5B89;&#x88C5;&#x5305;
sudo yum install -y yum-utils

# 3.&#x8BBE;&#x7F6E;&#x955C;&#x50CF;&#x7684;&#x4ED3;&#x5E93;
sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo # &#x9ED8;&#x8BA4;&#x7684;&#x662F;&#x56FD;&#x5916;&#x7684;

# docker&#x963F;&#x91CC;&#x4E91;&#x56FD;&#x5185;&#x955C;&#x50CF;&#x5730;&#x5740;,&#x63A8;&#x8350;&#x4F7F;&#x7528;&#x963F;&#x91CC;&#x4E91;&#x7684;
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

# 4. &#x5728;&#x5B89;&#x88C5;&#x4E4B;&#x524D;&#x5EFA;&#x8BAE;&#x66F4;&#x65B0;yum&#x66F4;&#x65B0;&#x7D22;&#x5F15;
sudo yum makecache fast

# 5. &#x5B89;&#x88C5;docker&#x76F8;&#x5173;&#x7684;
sudo yum install docker-ce docker-ce-cli containerd.io  # docker-ce &#x662F;&#x793E;&#x533A;&#x7248;&#x672C;&#x7684; docker-ee &#x662F;&#x4F01;&#x4E1A;&#x7248;&#x672C;&#x7684;

# 6. &#x5982;&#x679C;&#x60F3;&#x8981;&#x5B89;&#x88C5;&#x4E0D;&#x662F;&#x6700;&#x65B0;&#x7248;&#x672C;&#x7684;,&#x4E5F;&#x53EF;&#x4EE5;&#x6307;&#x5B9A;&#x5B89;&#x88C5;&#x7684;&#x7248;&#x672C;
sudo yum install docker-ce-&lt;VERSION_STRING&gt; docker-ce-cli-&lt;VERSION_STRING&gt; containerd.io

# 7. &#x5B89;&#x88C5;&#x5B8C;&#x6210;&#x4E4B;&#x540E;&#x5C31;&#x53EF;&#x4EE5;&#x542F;&#x52A8;docker,&#x6700;&#x540E;helloworld

sudo systemctl start docker

# 8. &#x67E5;&#x770B;docker&#x7248;&#x672C;,&#x5224;&#x65AD;&#x662F;&#x5426;&#x542F;&#x52A8;
docker version
</code></pre>
<p><img src="./imgs/&#x5FAE;&#x4FE1;&#x622A;&#x56FE;_20210321141242.png" alt=""></p>
<p><strong>^_^</strong></p>
<pre><code class="lang-shell"># &#x67E5;&#x770B;docker&#x91CC;&#x6240;&#x6709;&#x955C;&#x50CF;
[root@izijy66dzll7bdz ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED       SIZE
hello-world   latest    d1165f221234   2 weeks ago   13.3kB
[root@izijy66dzll7bdz ~]#
</code></pre>
<blockquote>
<p><strong>&#x5378;&#x8F7D;docker</strong></p>
</blockquote>
<pre><code class="lang-shell">Uninstall Docker Engine
Uninstall the Docker Engine, CLI, and Containerd packages:
# &#x5378;&#x8F7D;&#x4F9D;&#x8D56;
$ sudo yum remove docker-ce docker-ce-cli containerd.io
Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:
# &#x5220;&#x9664;&#x8D44;&#x6E90;(&#x76EE;&#x5F55;)(linux&#x7CFB;&#x7EDF;&#x4E00;&#x5207;&#x7686;&#x6587;&#x4EF6;)
$ sudo rm -rf /var/lib/docker
You must delete any edited configuration files manually.
# /var/lib/docker docker &#x7684;&#x9ED8;&#x8BA4;&#x5DE5;&#x4F5C;&#x8DEF;&#x5F84;
</code></pre>
<blockquote>
<p>&#x963F;&#x91CC;&#x4E91;&#x955C;&#x50CF;&#x52A0;&#x901F;</p>
</blockquote>
<p>&#x767B;&#x5F55;&#x963F;&#x91CC;&#x4E91;</p>
<p>&#x627E;&#x5230;&#x955C;&#x50CF;&#x52A0;&#x901F;&#x670D;&#x52A1;</p>
<p>&#x64CD;&#x4F5C;&#x6587;&#x6863; &#x4E0D;&#x540C;&#x7684;&#x7CFB;&#x7EDF;,&#x64CD;&#x4F5C;&#x4E0D;&#x540C; &#x52A0;&#x901F;&#x5668;&#x5730;&#x5740;:<a href="https://hozxrmk0.mirror.aliyuncs.com" target="_blank">https://hozxrmk0.mirror.aliyuncs.com</a> &#x914D;&#x7F6E;&#x4F7F;&#x7528; ```xml</p>
<p>&#x5B89;&#x88C5;&#xFF0F;&#x5347;&#x7EA7;Docker&#x5BA2;&#x6237;&#x7AEF; &#x63A8;&#x8350;&#x5B89;&#x88C5;1.10.0&#x4EE5;&#x4E0A;&#x7248;&#x672C;&#x7684;Docker&#x5BA2;&#x6237;&#x7AEF;&#xFF0C;&#x53C2;&#x8003;&#x6587;&#x6863; docker-ce</p>
<p>&#x914D;&#x7F6E;&#x955C;&#x50CF;&#x52A0;&#x901F;&#x5668; &#x9488;&#x5BF9;Docker&#x5BA2;&#x6237;&#x7AEF;&#x7248;&#x672C;&#x5927;&#x4E8E; 1.10.0 &#x7684;&#x7528;&#x6237;</p>
<p>&#x60A8;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4FEE;&#x6539;daemon&#x914D;&#x7F6E;&#x6587;&#x4EF6;/etc/docker/daemon.json&#x6765;&#x4F7F;&#x7528;&#x52A0;&#x901F;&#x5668;</p>
<p>&#x6267;&#x884C;&#x4EE5;&#x4E0B;4&#x6B65;&#x9AA4;&#x547D;&#x4EE4;: </p>
<pre><code class="lang-shell">sudo mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json &lt;&lt;-&apos;EOF&apos;
{
  &quot;registry-mirrors&quot;: [&quot;https://hozxrmk0.mirror.aliyuncs.com&quot;]
}
EOF

sudo systemctl daemon-reload

sudo systemctl restart docker
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="docker01 docker能干嘛.html" class="navigation navigation-prev " aria-label="Previous page: docker01 docker能干嘛">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="docker03 docker原理.html" class="navigation navigation-next " aria-label="Next page: docker03 docker原理">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"docker02 安装docker","level":"1.3","depth":1,"next":{"title":"docker03 docker原理","level":"1.4","depth":1,"path":"docker03 docker原理.md","ref":"docker03 docker原理.md","articles":[]},"previous":{"title":"docker01 docker能干嘛","level":"1.2","depth":1,"path":"docker01 docker能干嘛.md","ref":"docker01 docker能干嘛.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"docker02 安装docker.md","mtime":"2021-04-17T07:00:09.689Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-04-17T07:50:48.567Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

